//
//  HeadView.m
//  StationManager
//
//  Created by 张佳强 on 17/3/4.
//  Copyright © 2017年 Helong. All rights reserved.
//

#import "HeadView.h"

@implementation HeadView

- (instancetype)init {
    
    self = [super init];
    if (self) {
        
       
        self.backgroundColor = [UIColor whiteColor];
        self.nameLabel = [[UILabel alloc]init];
        self.nameLabel.text = @"台站名称：";
        self.nameLabel.font = [UIFont systemFontOfSize:13.0];
        [self addSubview:self.nameLabel];
        
        self.stationName = [[UILabel alloc]init];
        self.stationName.font = [UIFont systemFontOfSize:13.0];
        [self addSubview:self.stationName];
        
        self.numberLabel = [[UILabel alloc]init];
        self.numberLabel.text = @"台  站  号：";
        self.numberLabel.font = [UIFont systemFontOfSize:13.0];
        [self addSubview:self.numberLabel];
        
        self.stationNumber = [[UILabel alloc]init];
        self.stationNumber.font = [UIFont systemFontOfSize:13.0];
        [self addSubview:self.stationNumber];
        
        self.datelabel = [[UILabel alloc]init];
        self.datelabel.text = @"维护日期：";
        self.datelabel.font = [UIFont systemFontOfSize:13.0];
        [self addSubview:self.datelabel];
        
        self.personlabel = [[UILabel alloc]init];
        self.personlabel.text = @"维护人员：";
        self.personlabel.font = [UIFont systemFontOfSize:13.0];
        [self addSubview:self.personlabel];
        
        self.dateTimeLabel = [[UILabel alloc]init];
        self.dateTimeLabel.font = [UIFont systemFontOfSize:13.0];
        [self addSubview:self.dateTimeLabel];
//        [self setDateTextField];

        self.personTextField = [[UITextField alloc]init];
        self.personTextField.font = [UIFont systemFontOfSize:13.0];
        [self addSubview:self.personTextField];
        
        self.batterylabel = [[UILabel alloc]init];
        self.batterylabel.text = @"  蓄电池";
        self.batterylabel.font = [UIFont systemFontOfSize:15.0];
        self.batterylabel.backgroundColor = [UIColor colorWithRed:239/255.0 green:239/255.0 blue:244/255.0 alpha:1.0];
        [self addSubview:self.batterylabel];
        
        UILabel * line = [[UILabel alloc]init];
        line.backgroundColor = [UIColor blackColor];
        [self addSubview:line];
                
//        self.arrowImageView = [[UIImageView alloc]init];
//        self.arrowImageView.image = [UIImage imageNamed:@"jiantou1"];
//        [self addSubview:self.arrowImageView];
        
        [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@10);
            make.top.equalTo(@5);
            make.width.mas_equalTo(70);
            make.height.mas_equalTo(40);
        }];
        
        [self.stationName mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.nameLabel.mas_right).offset(5);
            make.top.equalTo(@5);
            make.width.mas_equalTo(SCREEN_WIDTH-80);
            make.height.mas_equalTo(40);
        }];
        
        [self.numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@10);
            make.top.equalTo(self.nameLabel.mas_bottom).offset(5);
            make.width.mas_equalTo(80);
            make.height.mas_equalTo(40);
            
        }];
        
        [self.stationNumber mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.numberLabel.mas_right).offset(-5);
            make.top.mas_equalTo(self.nameLabel.mas_bottom).offset(5);
            make.width.mas_equalTo(SCREEN_WIDTH-80);
            make.height.mas_equalTo(40);
        }];
        
        [self.datelabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@10);
            make.top.equalTo(self.numberLabel.mas_bottom).offset(5);
            make.width.mas_equalTo(70);
            make.height.mas_equalTo(40);
        }];
        
        [self.dateTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.datelabel.mas_right).offset(5);
            make.top.equalTo(self.numberLabel.mas_bottom).offset(10);
            make.right.equalTo(@0);
            make.height.mas_equalTo(30);
        }];
        
//        
//        [self.arrowImageView mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.right.equalTo(@-1);
//            make.top.equalTo(self.dateTimeLabel.mas_top).offset(6);
//            make.width.mas_equalTo(20);
//            make.height.mas_equalTo(20);
//        }];
        
        [self.personlabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@10);
            make.top.equalTo(self.datelabel.mas_bottom).offset(5);
            make.width.mas_equalTo(70);
            make.height.mas_equalTo(40);
        }];
        
        [self.personTextField mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.personlabel.mas_right).offset(5);
            make.top.equalTo(self.datelabel.mas_bottom).offset(5);
            make.right.equalTo(@-15);
            make.height.mas_equalTo(40);
        }];
        
        [line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.personlabel.mas_right).offset(5);
            make.top.equalTo(self.personTextField.mas_bottom);
            make.right.equalTo(@-15);
            make.height.mas_equalTo(1);
        }];
        
        [self.batterylabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@0);
            make.top.mas_equalTo(self.personlabel.mas_bottom).offset(10);
            make.width.mas_equalTo(SCREEN_WIDTH);
            make.height.mas_equalTo(35);
        }];
    }
    return self;
}

////设置选择日期
//- (void)setDateTextField {
//    
//    self.dateTextField = [[UITextField alloc]init];
//    NSDate *date = [NSDate date];
//    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
//    [formatter setDateFormat:@"YYYY-MM-dd"];
//    self.dateTextField.text = [formatter stringFromDate:date];
//    self.dateTextField.backgroundColor = [UIColor colorWithRed:239/255.0 green:239/255.0 blue:244/255.0 alpha:1.0];
//    self.dateTextField.font = [UIFont systemFontOfSize:13.0];
//    
//    self.datePicker = [[UIDatePicker alloc]init];
//    self.datePicker.datePickerMode = UIDatePickerModeDate;
//    [self.datePicker addTarget:self action:@selector(dateChange) forControlEvents:UIControlEventValueChanged];
//    
//    UIToolbar * tool = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 40)];
//    UIBarButtonItem * done = [[UIBarButtonItem alloc]initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(doneClick)];
//    UIBarButtonItem * space = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
//    NSArray * array = @[space,done];
//    [tool setItems:array];
//    [self.dateTextField setInputAccessoryView:tool];
//    
//    self.dateTextField.inputView = self.datePicker;
//    [self addSubview:self.dateTextField];
//}
//
////点击键盘上的完成按钮
//- (void)doneClick {
//    
//    [self.dateTextField resignFirstResponder];
//}
//
////时间选择器的值的变化事件
//- (void)dateChange {
//    
//    NSDateFormatter * formatter = [[NSDateFormatter alloc]init];
//    formatter.dateFormat = @"yyyy-MM-dd";
//    NSString * date = [formatter stringFromDate:self.datePicker.date];
//    self.dateTextField.text = date;
//}

@end
